<?php

require_once 'database.php';
require_once 'common.php';

session_start();

//Get information from the post
$strTaskName = $_POST['task_name'];
$strTaskDesc = $_POST['task_description'];
$intEstimatedHours = $_POST['estimated_hours'];
$intStoryId = $_POST['story_id'];

//Insert new row into the database
$addTask = mysql_query("INSERT INTO task (story_id, task_name, task_description, estimated_hours, status) 
		VALUES ($intStoryId, '$strTaskName', '$strTaskDesc', $intEstimatedHours, 'Open')")
	or die("Problem reading table: " . mysql_error());

$intTaskId = mysql_insert_id();

//Create the return object
$objReturn = array();
$objReturn['code'] = "SUCCESS";
$objReturn['task_id'] = $intTaskId;

header("content-type:application/json");
echo json_encode($objReturn);